Skip to content

feat(blog): comments + reactions (giscus) and Cloudflare Web Analytics - #6

Merged
codemug merged 1 commit into
mainfrom
feat/blog-comments-analytics
Aug 1, 2026
Merged

codemug merged 1 commit into
mainfrom
feat/blog-comments-analytics

Conversation

@codemug

@codemug codemug commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Adds reader engagement to blog posts, entirely on GitHub + one privacy-first analytics beacon — no database, no heavy dependency.

Comments + upvotes (giscus → GitHub Discussions)

  • Comments.astro renders giscus, backed by this repo's Discussions (Announcements category, so readers can comment/react but can't open spam threads). Data and moderation live in GitHub; you reply natively.
  • Reactions = your upvotes. Comments + 👍 in one widget.
  • Theme-synced to the site's light/dark toggle via a MutationObserver, lazy-loaded, styled with the site's tokens.
  • Per-post opt-out: comments: false in frontmatter (new schema field, defaults to on). Renders on posts only.
  • Requires the giscus GitHub App installed on the repo (done).

Views (Cloudflare Web Analytics)

  • Beacon added site-wide in Base.astro, matching Cloudflare's official type="module" snippet, emitted verbatim via is:inline.
  • Renders only when CF_BEACON_TOKEN is set in src/consts.ts, so no broken script ships otherwise. The token is a public, write-only, site-scoped id (it appears in the served HTML by design) — not a secret.
  • No cookies, no DNS/proxy change needed for github.io. Counts start once deployed to the live domain (localhost hits aren't counted).

Verification

npm run build clean. Beacon renders once per page across homepage/blog index/posts with valid JSON; giscus mounts its iframe at runtime; comments absent from the homepage.

🤖 Generated with Claude Code

Comments and upvotes run entirely on GitHub via giscus (GitHub Discussions) — no database, no build dependency, data lives in this repo's Discussions. The component is theme-synced to the site's light/dark toggle, lazy-loaded, and each post can opt out with a 'comments: false' frontmatter flag. Page views use Cloudflare Web Analytics (privacy-first, no cookies); the beacon renders only when a public token is set in src/consts.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant